import { log } from 'console';
import React, { Component } from 'react'
import Demo from './components/demo';


export default class App extends Component {
  state = {
    count: 1,
    flag: true
  }
  // 挂载
  constructor(props: any) {
    super(props)
    console.log('父 constructor');
  }
  componentDidMount() {
    console.log('父 componentDidMount');
  }
  render(): React.ReactNode {
    console.log('父 render');
    const { count, flag } = this.state
    return (
      <div>
        {  <Demo flag={ flag } count={ count } addCount={ () => this.setState({ count: count + 1 }) }></Demo>}
        <hr /> 
        {count}
        <button onClick={() => this.setState({ count: count + 1 })}>+1</button>
        <button onClick={() => this.setState({ flag: !flag })}>11</button>
      </div>
    )
  }
  shouldComponentUpdate(): boolean {
    console.log('父 shouldComponentUpdate')
    return true
  }
  componentDidUpdate() {
    console.log('父 componentDidUpdate');
  }

}